
import java.io.Serializable;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author dtuanh
 */
public class WordImpl implements Word,Serializable {
    //ID pour identifier la classe serializable
 private static final long serialVersionUID = 2997L;
    private Category cat;
    private List ls_property = new ArrayList();
 
    public Category myCategory() throws RemoteException {
        return cat;
    }

    public void setCategory(Category cat) {
        this.cat = cat;
    }

    public Property[] myProperties() throws RemoteException {
        Property[] ret=new PropertyImpl[ls_property.size()];
      for(int i=0;i<ls_property.size();i++)
          ret[i]=(Property)ls_property.get(i);
        return ret;
    }

    public void addProperty(Property p) {
        this.ls_property.add(p);
    }

    public void addProperty(Property p[]) {
        for(int i=0;i<p.length;i++)
        this.ls_property.add(p[i]);
    }
    public String term;

    public String getTerm() throws RemoteException {
        return term;
    }

    public void setTerm(String term) {
        this.term = term;
    }

    //encoder le Word en fichier
    public String toFile() {
        String ret = "«" + term + "», <";
        try {
            //ajouter  property
          for(int i=0;i<ls_property.size();i++)
          {
              PropertyImpl tmp=(PropertyImpl)ls_property.get(i);
              if(i!=0)ret+=","+tmp.toFile();
              else
                  ret+=tmp.toFile();
          }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ret+">";
    }
}


